let digits17:string="23";
console.log(letterCombinations(digits17));

function letterCombinations(digits: string): string[] {
    let result:string[]=[];
    let arr: [number,string][] = [
        [2,"abc"],
        [3,"def"],
        [4,"ghi"],
        [5,"jkl"],
        [6,"mno"],
        [7,"pqrs"],
        [8,"tuv"],
        [9,"wxyz"]
      ];
      let map = new Map<number, string>(arr)
      if(digits==="")
        return  [];
      result=map.get(parseInt(digits[0]))!.split("")
    //   console.log(result);
      
      for(let i=1;i<digits.length;i++){
        let newStr=map.get(parseInt(digits[i]))!.split("")
        // console.log(newStr);
        
        result=combine(result,newStr);
      }
    return result;
};
function combine(strA:string[],strB:string[]):string[]{
    let result:string[]=[];
    for(let i=0;i<strA.length;i++){
        for(let j=0;j<strB.length;j++){
            result.push(strA[i]+strB[j])
        }
    }
    return result;
}